//*********************************************************************** // Monty_Hall.cpp // // this is an implementation of a puzzle which involves choosing a winning // choice from three possible choices. it is similar to the cunundrum // faced by contestants on "Let's Make A Deal" with Monty Hall - thus // the name Monty_Hall. // // INPUTS: // // OUTPUTS: // //*********************************************************************** // WARNING: none // //*********************************************************************** // IMPLEMENTATION NOTE: all files are in the executable working directory // //*********************************************************************** // created by: j. aleshunas // created on: 22 jun 05 // modified on: 31 oct 05 // // © 2005 John Aleshunas // //*********************************************************************** #include "Monty_Hall.h" void main(void) { // declare program variables bool bNot_done; int iMenu_response = 0; char cPause = 0; int iIteration_count; char cSwitch; // a simulation instance Simulation_instance clLMAD_sim; // initialize the loop variable to TRUE bNot_done = true; // loop until the loop variable is FALSE while(bNot_done) { // display the menu cout << endl << endl; // menu selections: cout << "==============================================================" << endl; // 1) play a single session (program maintains cumulative stats) cout << "1) Play a single session" << endl; // 2) run an auto-simulation for N iterations // (program displays cumulative stats for simulation) cout << "2) Run an auto-simulation for N iterations" << endl; // 3) view the cumulative stats cout << "3) View the cumulative stats" << endl; // 4) clear the cumulative stats cout << "4) Clear the cumulative stats" << endl; // 9) quit the program cout << "9) Quit the program" << endl << endl << endl; // get the menu selection cin >> iMenu_response; // switch statement to act on the menu selection switch(iMenu_response){ // case 1 - activate the simulation object case 1: // run the simulation clLMAD_sim.Run_simulation( ); // show the results clLMAD_sim.Show_results( ); cout <> iIteration_count; cout << endl << endl; cout << "Do you want to test switching (y/n)? "; cin >> cSwitch; cout << endl << endl; // run the simulation N times clLMAD_sim.Run_auto_simulation(iIteration_count, cSwitch); // show the results clLMAD_sim.Show_results( ); cout <